package com.cheetah.start.module.system.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cheetah.start.common.base.result.ResultController;
import com.cheetah.start.common.base.result.ResultTable;
import com.cheetah.start.common.query.PageQuery;
import com.cheetah.start.module.system.domain.ScheduleLog;
import com.cheetah.start.module.system.service.IScheduleLogService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

/**
 * Describe: 定时任务日志控制器
 * Author: 就眠仪式
 * createTime: 2019/10/23
 */
@RestController
@Api(tags = {"任务日志"})
@RequestMapping("/system/job/log")
public class ScheduleLogController extends ResultController {

    /**
     * Describe: 定时任务日志服务
     */
    @Autowired
    private IScheduleLogService scheduleLogService;

    /**
     * Describe: 获取定时任务日志列表视图
     * Param: modelAndView
     * Return: 定时任务日志列表视图
     */
    @GetMapping("main")
    public ModelAndView main() {
        return jumpPage("/system/schedule/log/main");
    }

    /**
     * Describe: 获取定时任务日志列表数据
     * Param: PageDomain
     * Return: Result
     */
    @GetMapping("data")
    public ResultTable data(ScheduleLog scheduleLogBean, PageQuery pageDomain) {
        Page<ScheduleLog> pageInfo = scheduleLogService.pageList(scheduleLogBean, pageDomain);
        return pageTable(pageInfo.getRecords(), pageInfo.getTotal());
    }
}
